/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package homework6;

/**
 *
 * @author Administrator
 */
import java.util.*; 
  
public class MainE2{ 
    public static void main(String []args){ 
           
        Scanner sc=new Scanner(System.in); 
       String a[]=new String [10]; 
       String c;
       int b[]=new int [10];
       int d;
       for(int i=0;i<a.length;i++){
           a[i]=sc.next();
       }
       for(int i=0;i<b.length;i++){
           b[i]=sc.nextInt();
       }
       for(int k=0;k<a.length-1;k++){ 
            for(int j=k+1;j<a.length;j++){ 
                if(a[k].compareTo(a[j])>0){ 
                    c=a[k]; 
                    a[k]=a[j]; 
                    a[j]=c;  
                    d=b[k]; 
                    b[k]=b[j]; 
                    b[j]=d;
                } 
            } 
  
       }
       for(int i=0;i<10;i++){
           System.out.println(a[i]+","+b[i]);
       }
    }
}
